From de07008fdd4c20763177ff977acbbc544fb850f7 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 10 Oct 2008 10:03:28 +0100 Subject: [PATCH] xend: Fix the detection of the upmost bridge in the python function find_parent(). Signed-off-by: Dexuan Cui --- tools/python/xen/util/pci.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/python/xen/util/pci.py b/tools/python/xen/util/pci.py index 56e2c9e633..ef9bb4fda6 100644 --- a/tools/python/xen/util/pci.py +++ b/tools/python/xen/util/pci.py @@ -400,12 +400,8 @@ class PciDevice: lst = target.split('/') parent = lst[len(lst)-2] if parent[0:3] == 'pci': - parent = parent[3:] - lst = parent.split(':') - dom = int(lst[0], 16) - bus = int(lst[1], 16) - dev = 0 - func = 0 + # We have reached the upmost one. + return None else: lst = parent.split(':') dom = int(lst[0], 16) @@ -424,7 +420,10 @@ class PciDevice: (dom, b, d, f) = self.find_parent() dev = dev_parent = PciDevice(dom, b, d, f) while dev_parent.dev_type != DEV_TYPE_PCIe_BRIDGE: - (dom, b, d, f) = dev_parent.find_parent() + parent = dev_parent.find_parent() + if parent is None: + break + (dom, b, d, f) = parent dev = dev_parent dev_parent = PciDevice(dom, b, d, f) return dev -- 2.30.2